home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #5 / Amiga Plus CD - 2000 - No. 5.iso / Tools / Dev / fpc / amigaunits / inputevent.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2000-01-01  |  9.4 KB  |  288 lines

  1. {
  2.     This file is part of the Free Pascal run time library.
  3.  
  4.     A file in Amiga system run time library.
  5.     Copyright (c) 1998-2000 by Nils Sjoholm
  6.     member of the Amiga RTL development team.
  7.  
  8.     See the file COPYING.FPC, included in this distribution,
  9.     for details about the copyright.
  10.  
  11.     This program is distributed in the hope that it will be useful,
  12.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14.  
  15.  **********************************************************************}
  16.  
  17. unit inputevent;
  18.  
  19. INTERFACE
  20.  
  21. uses exec, utility, timer;
  22.  
  23. const
  24.  
  25. {------ constants -------------------------------------------------}
  26.  
  27. {   --- InputEvent.ie_Class --- }
  28. { A NOP input event }
  29.     IECLASS_NULL        = $00;
  30. { A raw keycode from the keyboard device }
  31.     IECLASS_RAWKEY      = $01;
  32. { The raw mouse report from the game port device }
  33.     IECLASS_RAWMOUSE    = $02;
  34. { A private console event }
  35.     IECLASS_EVENT       = $03;
  36. { A Pointer Position report }
  37.     IECLASS_POINTERPOS  = $04;
  38. { A timer event }
  39.     IECLASS_TIMER       = $06;
  40. { select button pressed down over a Gadget (address in ie_EventAddress) }
  41.     IECLASS_GADGETDOWN  = $07;
  42. { select button released over the same Gadget (address in ie_EventAddress) }
  43.     IECLASS_GADGETUP    = $08;
  44. { some Requester activity has taken place.  See Codes REQCLEAR and REQSET }
  45.     IECLASS_REQUESTER   = $09;
  46. { this is a Menu Number transmission (Menu number is in ie_Code) }
  47.     IECLASS_MENULIST    = $0A;
  48. { User has selected the active Window's Close Gadget }
  49.     IECLASS_CLOSEWINDOW = $0B;
  50. { this Window has a new size }
  51.     IECLASS_SIZEWINDOW  = $0C;
  52. { the Window pointed to by ie_EventAddress needs to be refreshed }
  53.     IECLASS_REFRESHWINDOW = $0D;
  54. { new preferences are available }
  55.     IECLASS_NEWPREFS    = $0E;
  56. { the disk has been removed }
  57.     IECLASS_DISKREMOVED = $0F;
  58. { the disk has been inserted }
  59.     IECLASS_DISKINSERTED = $10;
  60. { the window is about to be been made active }
  61.     IECLASS_ACTIVEWINDOW = $11;
  62. { the window is about to be made inactive }
  63.     IECLASS_INACTIVEWINDOW = $12;
  64. { extended-function pointer position report (V36) }
  65.     IECLASS_NEWPOINTERPOS  = $13;
  66. { Help key report during Menu session (V36) }
  67.     IECLASS_MENUHELP       = $14;
  68. { the Window has been modified with move, size, zoom, or change (V36) }
  69.     IECLASS_CHANGEWINDOW   = $15;
  70.  
  71.  
  72.  
  73. { the last class }
  74.  
  75.     IECLASS_MAX         = $15;
  76.  
  77. {  --- InputEvent.ie_SubClass --- }
  78. {  IECLASS_NEWPOINTERPOS }
  79. {      like IECLASS_POINTERPOS }
  80.  IESUBCLASS_COMPATIBLE  = $00;
  81. {      ie_EventAddress points to struct IEPointerPixel }
  82.  IESUBCLASS_PIXEL       = $01;
  83. {      ie_EventAddress points to struct IEPointerTablet }
  84.  IESUBCLASS_TABLET      = $02;
  85.  
  86. { pointed to by ie_EventAddress for IECLASS_NEWPOINTERPOS,
  87.  * and IESUBCLASS_PIXEL.
  88.  *
  89.  * You specify a screen and pixel coordinates in that screen
  90.  * at which you'd like the mouse to be positioned.
  91.  * Intuition will try to oblige, but there will be restrictions
  92.  * to positioning the pointer over offscreen pixels.
  93.  *
  94.  * IEQUALIFIER_RELATIVEMOUSE is supported for IESUBCLASS_PIXEL.
  95.  }
  96. Type
  97.  
  98.    pIEPointerPixel = ^tIEPointerPixel;
  99.    tIEPointerPixel = record
  100.     iepp_Screen : Pointer;   { pointer to an open screen }
  101.     iepp_Position : record
  102.        x,y : Integer;
  103.     end;
  104.    END;
  105.  
  106. { pointed to by ie_EventAddress for IECLASS_NEWPOINTERPOS,
  107.  * and IESUBCLASS_TABLET.
  108.  *
  109.  * You specify a range of values and a value within the range
  110.  * independently for each of X and Y (the minimum value of
  111.  * the ranges is always normalized to 0).
  112.  *
  113.  * Intuition will position the mouse proportionally within its
  114.  * natural mouse position rectangle limits.
  115.  *
  116.  * IEQUALIFIER_RELATIVEMOUSE is not supported for IESUBCLASS_TABLET.
  117.  }
  118.  
  119.    pIEPointerTablet = ^tIEPointerTablet;
  120.    tIEPointerTablet = record
  121.     iept_Range : record       { 0 is min, these are max      }
  122.        x,y : Word;
  123.     end;
  124.     iept_Value : record       { between 0 AND iept_Range     }
  125.        x,y : Word;
  126.     end;
  127.     iept_Pressure : Word;  { -128 to 127 (unused, set to 0)  }
  128.    END;
  129.  
  130. { The ie_EventAddress of an IECLASS_NEWPOINTERPOS event of subclass
  131.  * IESUBCLASS_NEWTABLET points at an IENewTablet structure.
  132.  *
  133.  *
  134.  * IEQUALIFIER_RELATIVEMOUSE is not supported for IESUBCLASS_NEWTABLET.
  135.  }
  136.  
  137.  pIENewTablet = ^tIENewTablet;
  138.  tIENewTablet = record
  139.     { Pointer to a hook you wish to be called back through, in
  140.      * order to handle scaling.  You will be provided with the
  141.      * width and height you are expected to scale your tablet
  142.      * to, perhaps based on some user preferences.
  143.      * If NULL, the tablet's specified range will be mapped directly
  144.      * to that width and height for you, and you will not be
  145.      * called back.
  146.      }
  147.     ient_CallBack : pHook;
  148.  
  149.     { Post-scaling coordinates and fractional coordinates.
  150.      * DO NOT FILL THESE IN AT THE TIME THE EVENT IS WRITTEN!
  151.      * Your driver will be called back and provided information
  152.      * about the width and height of the area to scale the
  153.      * tablet into.  It should scale the tablet coordinates
  154.      * (perhaps based on some preferences controlling aspect
  155.      * ratio, etc.) and place the scaled result into these
  156.      * fields.  The ient_ScaledX and ient_ScaledY fields are
  157.      * in screen-pixel resolution, but the origin ( [0,0]-point )
  158.      * is not defined.  The ient_ScaledXFraction and
  159.      * ient_ScaledYFraction fields represent sub-pixel position
  160.      * information, and should be scaled to fill a UWORD fraction.
  161.      }
  162.     ient_ScaledX, ient_ScaledY,
  163.     ient_ScaledXFraction, ient_ScaledYFraction : WORD;
  164.  
  165.     { Current tablet coordinates along each axis: }
  166.     ient_TabletX, ient_TabletY : ULONG;
  167.  
  168.     { Tablet range along each axis.  For example, if ient_TabletX
  169.      * can take values 0-999, ient_RangeX should be 1000.
  170.      }
  171.     ient_RangeX, ient_RangeY : ULONG;
  172.  
  173.     { Pointer to tag-list of additional tablet attributes.
  174.      * See <intuition/intuition.h> for the tag values.
  175.      }
  176.     ient_TagList : pTagItem;
  177.  end;
  178.  
  179.  
  180. CONST
  181. {   --- InputEvent.ie_Code ---   }
  182. { IECLASS_RAWKEY }
  183.     IECODE_UP_PREFIX            = $80;
  184.     IECODE_KEY_CODE_FIRST       = $00;
  185.     IECODE_KEY_CODE_LAST        = $77;
  186.     IECODE_COMM_CODE_FIRST      = $78;
  187.     IECODE_COMM_CODE_LAST       = $7F;
  188.  
  189. { IECLASS_ANSI }
  190.     IECODE_C0_FIRST             = $00;
  191.     IECODE_C0_LAST              = $1F;
  192.     IECODE_ASCII_FIRST          = $20;
  193.     IECODE_ASCII_LAST           = $7E;
  194.     IECODE_ASCII_DEL            = $7F;
  195.     IECODE_C1_FIRST             = $80;
  196.     IECODE_C1_LAST              = $9F;
  197.     IECODE_LATIN1_FIRST         = $A0;
  198.     IECODE_LATIN1_LAST          = $FF;
  199.  
  200. { IECLASS_RAWMOUSE }
  201.     IECODE_LBUTTON              = $68;  { also uses IECODE_UP_PREFIX }
  202.     IECODE_RBUTTON              = $69;
  203.     IECODE_MBUTTON              = $6A;
  204.     IECODE_NOBUTTON             = $FF;
  205.  
  206. { IECLASS_EVENT }
  207.     IECODE_NEWACTIVE            = $01;  { active input window changed }
  208.     IECODE_NEWSIZE              = $02;  { resize of window }
  209.     IECODE_REFRESH              = $03;  { refresh of window }
  210.  
  211. { IECLASS_REQUESTER Codes }
  212. { REQSET is broadcast when the first Requester (not subsequent ones) opens
  213.  * in the Window
  214.  }
  215.     IECODE_REQSET               = $01;
  216. { REQCLEAR is broadcast when the last Requester clears out of the Window }
  217.     IECODE_REQCLEAR             = $00;
  218.  
  219.  
  220. {   --- InputEvent.ie_Qualifier --- }
  221.     IEQUALIFIER_LSHIFT          = $0001;
  222.     IEQUALIFIER_RSHIFT          = $0002;
  223.     IEQUALIFIER_CAPSLOCK        = $0004;
  224.     IEQUALIFIER_CONTROL         = $0008;
  225.     IEQUALIFIER_LALT            = $0010;
  226.     IEQUALIFIER_RALT            = $0020;
  227.     IEQUALIFIER_LCOMMAND        = $0040;
  228.     IEQUALIFIER_RCOMMAND        = $0080;
  229.     IEQUALIFIER_NUMERICPAD      = $0100;
  230.     IEQUALIFIER_REPEAT          = $0200;
  231.     IEQUALIFIER_INTERRUPT       = $0400;
  232.     IEQUALIFIER_MULTIBROADCAST  = $0800;
  233.     IEQUALIFIER_MIDBUTTON       = $1000;
  234.     IEQUALIFIER_RBUTTON         = $2000;
  235.     IEQUALIFIER_LEFTBUTTON      = $4000;
  236.     IEQUALIFIER_RELATIVEMOUSE   = $8000;
  237.  
  238.     IEQUALIFIERB_LSHIFT         = 0;
  239.     IEQUALIFIERB_RSHIFT         = 1;
  240.     IEQUALIFIERB_CAPSLOCK       = 2;
  241.     IEQUALIFIERB_CONTROL        = 3;
  242.     IEQUALIFIERB_LALT           = 4;
  243.     IEQUALIFIERB_RALT           = 5;
  244.     IEQUALIFIERB_LCOMMAND       = 6;
  245.     IEQUALIFIERB_RCOMMAND       = 7;
  246.     IEQUALIFIERB_NUMERICPAD     = 8;
  247.     IEQUALIFIERB_REPEAT         = 9;
  248.     IEQUALIFIERB_INTERRUPT      = 10;
  249.     IEQUALIFIERB_MULTIBROADCAST = 11;
  250.     IEQUALIFIERB_MIDBUTTON      = 12;
  251.     IEQUALIFIERB_RBUTTON        = 13;
  252.     IEQUALIFIERB_LEFTBUTTON     = 14;
  253.     IEQUALIFIERB_RELATIVEMOUSE  = 15;
  254.  
  255.  
  256. {------ InputEvent ------------------------------------------------}
  257.  
  258.     type
  259.        pInputEvent = ^tInputEvent;
  260.        tInputEvent = record
  261.             ie_NextEvent : pInputEvent;
  262.             ie_Class : BYTE;
  263.             ie_SubClass : BYTE;
  264.             ie_Code : WORD;
  265.             ie_Qualifier : WORD;
  266.             ie_position : record
  267.                 case longint of
  268.                    0 : ( ie_xy : record
  269.                         ie_x : Integer;
  270.                         ie_y : Integer;
  271.                      end );
  272.                    1 : ( ie_addr : APTR );
  273.                    2 : ( ie_dead : record
  274.                         ie_prev1DownCode : BYTE;
  275.                         ie_prev1DownQual : BYTE;
  276.                         ie_prev2DownCode : BYTE;
  277.                         ie_prev2DownQual : BYTE;
  278.                      end );
  279.                 end;
  280.             ie_TimeStamp : tTimeVal;
  281.          end;
  282.  
  283. IMPLEMENTATION
  284.  
  285. end.
  286.  
  287.  
  288.